package io.geekidea.springboot;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;

import java.util.Collections;

/**
 * @Description 交互式代码生成
 * @Date  2024/8/1 14:37
 * @Author 余乐
 **/
public class CodeGenerator {

    public static void main(String[] args) {
        String url = "jdbc:mysql://192.168.10.181:3306/guozi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&remarks=true&useInformationSchema=true";
        // 代码生成器
        FastAutoGenerator.create(url, "root", "123456")
                .globalConfig(builder -> builder
                        .author("mybatis-plus-generator")
                        .outputDir("D:/workspase/guozi/src/main/java")
                        .commentDate("yyyy-MM-dd")
                        .enableSpringdoc()
                        .enableSwagger()
                )
                .packageConfig(builder ->
                        builder.parent("com.danghong") // 设置父包名
                                .moduleName("guozi") // 设置父包模块名
                                // 设置mapperXml生成路径
                                .pathInfo(Collections.singletonMap(OutputFile.xml, "D:\\workspase\\guozi\\src\\main\\resources\\mapper"))
                )
                .strategyConfig(builder -> builder
                        .entityBuilder()
                        .enableLombok()
                )
                .templateEngine(new VelocityTemplateEngine())
                .execute();
    }

}
